/*
 * MIT License
 *
 * Copyright (c) 2023 北京凯特伟业科技有限公司
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.je.message.vo;

import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.List;

/**
 * 微信企业号消息内容
 *
 * @author zhangshuaipeng
 */
public class DdMsgVo extends MessageVo{
    /**
     * 接收用户 如果值为@all 则发送给全部的人
     */
    private String userIds;
    /**
     * 接收部门
     */
    private String deptIds;
    /**
     * 消息类型    文字：WZ  图片：TP 语音：YY  文件：WJ markdown:MD OA:OA 卡片：KP 链接LJ
     */
    private String type;
    /**
     * 附件地址
     */
    private String fileKey;
    /**
     * 附件名称
     */
    private String fileName;
    /**
     * Markdown Text
     */
    private String mdText;
    /**
     * 标题
     */
    private String title;
    /**
     * 内容
     */
    private String content;
    /**
     * 原文链接地址
     */
    private String sourceUrl;
    /**
     * 作者
     */
    private String author;

    /**
     * OA消息PCURL
     */
    private String pcUrl;
    /**
     * OA移动端URL
     */
    private String mobileUrl;

    /**
     * OA消息头部的背景颜色
     */
    private String bgColor;

    /**
     * OA消息表单内容-最多显示6个
     */
    private List<OapiMessageCorpconversationAsyncsendV2Request.Form> listFrom;

    /**
     * OA消息体的标题
     */
    private String bodyTitle;

    /**
     * OA消息自定义的附件数目。此数字仅供显示，钉钉不作验证
     */
    private String fileCount;
    /**
     * OA消息单行富文本信息的数目
     */
    private String richNum;
    /**
     * OA消息单行富文本信息的单位
     */
    private String richUnit;
    /**
     * 消息体的关键字
     */
    private String formKey;
    /**
     * 消息体的关键字对应的值
     */
    private String formValue;

    /**
     * 使用独立跳转ActionCard样式时的按钮排列方式，竖直排列(0)，横向排列(1)；
     */
    private String btnOrientation;

    /**
     * 卡片按钮集合
     */
    private List<OapiMessageCorpconversationAsyncsendV2Request.BtnJsonList> btnJsonList;

    /**
     * 集团公司ID
     */
    private String jtgsId;

    public DdMsgVo() {
    }

    /**
     * 图片/语音/MD/文件
     *
     * @param userIds          用户
     * @param type             类型
     * @param filePathOrMdText 附件地址或者MD内容
     * @param fileNameOrMdName 附件名称或者MD标题
     */
    public DdMsgVo(String userIds, String type, String filePathOrMdText, String fileNameOrMdName) {
        this.userIds = userIds;
        this.type = type;
        if (type.equals("MD")) {
            this.content = filePathOrMdText;
            this.title = fileNameOrMdName;
        } else {
            this.mdText = filePathOrMdText;
            this.fileName = fileNameOrMdName;
        }
    }

    /**
     * 卡片
     *
     * @param userIds        用户
     * @param type           类型
     * @param cardTitle      标题
     * @param markDownText   内容
     * @param btnOrientation 按钮排列方式
     * @param btnJsonList    按钮集合
     */
    public DdMsgVo(String userIds, String type, String cardTitle, String markDownText, String btnOrientation,
                   List<OapiMessageCorpconversationAsyncsendV2Request.BtnJsonList> btnJsonList) {
        this.userIds = userIds;
        this.type = type;
        this.title = cardTitle;
        this.content = markDownText;
        this.btnOrientation = btnOrientation;
        this.btnJsonList = btnJsonList;
    }

    /**
     * 文字
     *
     * @param userIds 用户
     * @param type    类型
     * @param context 内容
     */
    public DdMsgVo(String userIds, String type, String context) {
        this.userIds = userIds;
        this.type = type;
        this.content = context;
    }

    /**
     * 链接
     *
     * @param userIds  用户
     * @param type     类型
     * @param fileKey  附件KEY
     * @param fileName 附件名称
     * @param title    标题
     * @param text     内容
     * @param url      地址
     */
    public DdMsgVo(String userIds, String type, String fileKey, String fileName, String title, String text, String url) {
        this.userIds = userIds;
        this.type = type;
        this.fileKey = fileKey;
        this.fileName = fileName;
        this.title = title;
        this.content = text;
        this.sourceUrl = url;
    }

    /**
     * OA
     *
     * @param userIds     用户
     * @param type        类型
     * @param fileKey     附件KEY
     * @param fileName    附件名称
     * @param url         移动端url
     * @param pcUrl       pcURL
     * @param headText    表头标题
     * @param headColor   表头背景色
     * @param listFrom    表单内容 key：value
     * @param richNum     rich数目
     * @param richUnit    rich单位
     * @param bodyContent 内容
     * @param bodyTitle   表单标题
     * @param fileCount   附件数量
     * @param author      作者
     */
    public DdMsgVo(String userIds, String type, String fileKey, String fileName, String url, String pcUrl, String headText,
                   String headColor, List<OapiMessageCorpconversationAsyncsendV2Request.Form> listFrom, String richNum, String richUnit, String bodyContent, String bodyTitle, String fileCount, String author) {
        this.userIds = userIds;
        this.type = type;
        this.fileKey = fileKey;
        this.fileName = fileName;
        this.mobileUrl = url;
        this.pcUrl = pcUrl;
        this.title = headText;
        this.bgColor = headColor;
        this.listFrom = listFrom;
        this.richNum = richNum;
        this.richUnit = richUnit;
        this.content = bodyContent;
        this.bodyTitle = bodyTitle;
        this.fileCount = fileCount;
        this.author = author;
    }


    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

}
